package cn.life.common.push;

import cn.life.common.push.hw.HwPushConfig;
import cn.life.common.push.ios.IosPushConfig;
import cn.life.common.push.jg.JgPushConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;

/**
 * @Description:
 * @Author 李佳明
 * @Date 2018-09-10 15:02
 */
@Order(99)
@Configuration
@PropertySource({"classpath:config.properties"})
public class PushConfiguration {

    @Autowired
    private Environment env;

    @Bean(name="hwPushConfig")
    public HwPushConfig hwPushConfig(){
        HwPushConfig hwPushConfig = new HwPushConfig();
        hwPushConfig.setAppId(env.getProperty("hw.appId"));
        hwPushConfig.setAppSecret(env.getProperty("hw.appSecret"));
        hwPushConfig.setImgUrl(env.getProperty("hw.imgUrl"));
        return hwPushConfig;
    }

    @Bean(name="jgPushConfig")
    public JgPushConfig jgPushConfig(){
        JgPushConfig jgPushConfig = new JgPushConfig();
        jgPushConfig.setAppKey(env.getProperty("jg.appKey"));
        jgPushConfig.setSecretKey(env.getProperty("jg.masterSecret"));
        return jgPushConfig;
    }

    @Bean(name="iosPushConfig")
    public IosPushConfig iosPushConfig(){
        IosPushConfig iosPushConfig = new IosPushConfig();
        iosPushConfig.setP12Path(env.getProperty("ios.path"));
        iosPushConfig.setP12Pwd(env.getProperty("ios.pwd"));
        iosPushConfig.setP12Formal(env.containsProperty("ios.formal"));
        return iosPushConfig;
    }
}
